package com.jl.core.mapper;

import com.jl.core.model.SysProxy;
import com.jl.core.model.resp.MyPlayer;
import com.jl.core.model.resp.MyProxy;
import com.jl.core.model.resp.PopularizationResp;
import com.jl.utils.MyMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface SysProxyMapper extends MyMapper<SysProxy> {
    @Select("select user_id from sys_proxy where proxy_user=#{userId}")
    String selectInvCode(@Param("userId") Integer userId);

    List<MyPlayer> selectMyPlayer(@Param("queryUserId")Integer queryUserId,@Param("userId") Integer userId);

    @Select("select count(*) from sys_proxy where user_id=#{userId} and DATE_FORMAT(create_time,'%Y-%m-%d')=DATE_FORMAT(now(),'%Y-%m-%d') and type=1")
    Integer selectPlayerAdd(@Param("userId") Integer userId);

    @Update("update sys_proxy set type=2 where proxy_user=#{userId}")
    void updatePlayerToProxy(@Param("userId") Integer userId);

    List<MyProxy> selectMyProxy(@Param("queryUserId") Integer queryUserId, @Param("userId") Integer userId);

    @Select("select count(*) from sys_proxy where user_id=#{userId} and DATE_FORMAT(create_time,'%Y-%m-%d')=DATE_FORMAT(now(),'%Y-%m-%d') and type=2")
    Integer selectProxyAdd(@Param("userId") Integer userId);

    PopularizationResp selectMyPopularization(@Param("userId") Integer userId);

    @Update("update user set proxy_rate=#{proxyRate} where id=#{userId}")
    void updateProxyRate(@Param("userId") Integer userId, @Param("proxyRate") String proxyRate);
}
